<?php

namespace app\model;

use EasyWeChat\Factory;

class Wxmini

{

	static function make()
	{
		$Configdata = Config::getconfig('miniprogram');
		return Factory::miniProgram([
			'app_id' => trim($Configdata['app_id']),
			'secret' => trim($Configdata['secret'])
		]);
	}

	static function urllink($param)
	{
		$Wxmini = Wxmini::make();

		$url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token=' . $Wxmini->access_token->getToken()['access_token'];

		$retlink = post($url, $param);

		return $retlink;
	}
	static function subscribemessage($tpl)
	{
		//订单支付
		$data['pay_tpl']['tid'] = 1221;     // 模板标题 id，可通过接口获取，也可登录小程序后台查看获取
		$data['pay_tpl']['kidList'] = [1, 2, 3, 4, 6];
		$data['pay_tpl']['sceneDesc'] = '通知用户订单已支付成功';   // 服务场景描述，非必填


		return $data[$tpl];
	}
}
